package com.zzx.bms.controller;

import com.zzx.bms.domain.User;
import com.zzx.bms.service.IBookService;
import com.zzx.bms.service.IBorrowService;
import com.zzx.bms.service.IUserService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.Date;

/**
 * Created by SamZhao on 2016/12/5.
 */
@Controller
@RequestMapping("/home")
public class HomeController {

    private static Logger logger = Logger.getLogger(HomeController.class);

    @Autowired
    private IBookService bookService;

    @Autowired
    private IUserService userService;

    @Autowired
    private IBorrowService borrowService;

    @RequestMapping(value = "/index")
    public String loginIndex(Model model, HttpSession session){
        int bookall = bookService.getBookTotal();
        int userall = userService.getUserTotal();
        int borrowall = borrowService.getBorrowTotal();
        model.addAttribute("bookall",bookall);
        model.addAttribute("userall",userall);
        model.addAttribute("borrowall",borrowall);
        return "home/index";
    }


}
